﻿@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-success text-white">
                    <h4 class="mb-0">微信授权登录成功</h4>
                </div>
                <div class="card-body">
                    <p><strong>OpenID:</strong> @ViewBag.OpenId</p>
                    @if (!string.IsNullOrEmpty(ViewBag.Nickname))
                    {
                        <p><strong>昵称:</strong> @ViewBag.Nickname</p>
                    }
                    else
                    {
                        <div class="alert alert-info">
                            <p>当前为静默授权，只能获取OpenID</p>
                            <a href="@Url.Action("AuthorizeUserInfo", "WeChat", new { returnUrl = Url.Action("Profile", "Home") })"
                               class="btn btn-primary btn-sm">获取用户信息</a>
                        </div>
                    }

                    <div class="mt-3">
                        <a href="@Url.Action("Profile", "Home")" class="btn btn-primary me-2">个人资料</a>
                        <a href="@Url.Action("Logout", "WeChat")" class="btn btn-secondary"
                           onclick="return confirm('确定要退出吗？')">退出登录</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
